package com.excel.qlexpress;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@AllArgsConstructor
@Getter
@NoArgsConstructor
public enum CheckErrorFunctionEnum {

    // 人员
    EMPLOY_NATION_CHECK("国籍的国家二字码错误","员工国籍", "com.excel.qlexpress.EmployQlFunction","checkEmployNationality","checkEmployNationality(employ.getNationality())",new Class[]{String.class}),
    EMPLOY_SEX_CODE_CHECK("性别错误","员工性别", "com.excel.qlexpress.EmployQlFunction","checkEmployGender","checkEmployGender(employ.getGender())",new Class[]{String.class}),
    EMPLOY_COUNTRY_CODE_CHECK("手机国家码错误","手机国家码", "com.excel.qlexpress.EmployQlFunction","checkEmployCountryCode","checkEmployCountryCode(employ.getCountryCode())",new Class[]{String.class}),
    EMPLOY_COUNTRY_CODE_CHECK_1("手机号码填写错误","手机号码", "com.excel.qlexpress.EmployQlFunction","checkEmployMobilePhone","checkEmployMobilePhone(employ.getCountryCode(),employ.getMobilePhone())",new Class[]{String.class,String.class}),
    EMPLOY_EMAIL_CHECK("邮箱格式不正确","员工邮箱", "com.excel.qlexpress.EmployQlFunction","checkEmployEmail","checkEmployEmail(employ.getEmail())",new Class[]{String.class}),
    EMPLOY_BIRTH_CHECK("生日格式错误，请使用yyyy-MM-dd的格式","员工生日", "com.excel.qlexpress.EmployQlFunction","checkEmployBirth","checkEmployBirth(employ.getBirthday())",new Class[]{String.class}),



    // 组织
    ORG_COST_CHECK("成本中心校验失败","组织-成本中心", "com.excel.qlexpress.OrgQlFunction","checkOrgCost","checkOrgCost(org_basic.getCostCenterInfoDefault(),org_basic.getCostCenterInfo())",new Class[]{String.class,String.class}),


    ;


    private String validTip;
    private String groupName;
    private String className;
    private String functionName;
    private String expression;
    private Class<?>[] parameterClassTypes;
    public static Map<String, CheckErrorFunctionEnum> CheckConditionMap = new LinkedHashMap<>();

    public static List<CheckErrorFunctionEnum> getExpressByGroup(String groupName) {
        List<CheckErrorFunctionEnum> list = new ArrayList<>();
        for (CheckErrorFunctionEnum e : CheckErrorFunctionEnum.values()) {
            if (e.getGroupName().equals(groupName)) {
                list.add(e);
            }
        }
        return list; // 如果找不到对应的name，则返回null
    }

    static {
        for (CheckErrorFunctionEnum e : CheckErrorFunctionEnum.values()) {
            CheckConditionMap.put(e.name(), e);
        }
    }


}